﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SysContext;

namespace DataAccessLayer
{
    public class AccountsTable
    {
        SysDataContext Data = new SysDataContext();
        /// <summary>
        /// Lấy tất cả các dữ liệu trong bảng Account
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="type"></param>
        /// <returns>Id,UserId,Type,</returns>
        public List<Account> SelectAccountAll(int UserId, string type)
        {
            var p = (from i in Data.Accounts
                    where i.Type == type && i.UserId == UserId
                    select i).ToList();
            return p.ToList();
        }
        /// <summary>
        /// Lấy Id của bảng Account
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="type"></param>
        /// <returns>Id</returns>
        public double GetAccountId(int UserId, string type)
        {
            Account AccountId = Data.Accounts.SingleOrDefault(p => p.UserId == UserId && p.Type == type);
            return AccountId.Id;
        }

        /// <summary>
        /// Insert dữ liệu vào bảng Account
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="Type"></param>
        /// <param name="Currency"></param>
        /// <param name="Amount"></param>
        public void InsertAccount(int UserID, string Type, string Currency, double Amount)
        {
            Data.Insertaccount(UserID, Type, Currency, Amount);
        }
    }
}
